//
//  HCCallInfoViewController.m
//  HelloCall
//
//  Created by WangYongpeng on 13-9-21.
//  Copyright (c) 2013年 HC. All rights reserved.
//

#import "HCCallInfoViewController.h"


@interface HCCallInfoViewController ()

@property (nonatomic, retain) HCCallInfo* callInfo;

@end

@implementation HCCallInfoViewController

@synthesize callInfo = m_callInfo;

- (id)init
{
    self = [super init];
    if (nil != self)
    {
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.

    self.title = @"话单详情";
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)dealloc
{
    self.callInfo = nil;
    
    [super dealloc];
}

- (void)showCallDetail:(HCCallInfo*)callInfo
{
    self.callInfo = callInfo;
    
    NSString* text = @"单个话单查看详情内容：\n\n";
    
    text = [text stringByAppendingFormat:@"客户来电号码：%@\n",self.callInfo.phoneNumber];
    text = [text stringByAppendingFormat:@"来源：%@\n",[self getCallSoucre]];
    NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"yyyy年MM月dd号 HH:mm:ss"];
    text = [text stringByAppendingFormat:@"初始时间：%@\n", [dateFormatter stringFromDate:self.callInfo.initTime]];
    text = [text stringByAppendingFormat:@"通话次数：%d\n", self.callInfo.callNumber];
    text = [text stringByAppendingFormat:@"通过时间：%d分钟\n", self.callInfo.sumCallTime];
    [dateFormatter setDateFormat:@"HH小时mm分钟"];
    text = [text stringByAppendingFormat:@"回访延时：%@\n", [dateFormatter stringFromDate:self.callInfo.visitDelay]];
    
    [self setDetailText:text];
}

- (NSString*)getCallSoucre
{
    NSString* callSoucreText = nil;
    
    switch (self.callInfo.callSourceType)
    {
        case CallSourceType_allocation:
        {
            callSoucreText = @"企业分配";
            break;
        }
        case CallSourceType_spread:
        {
            callSoucreText = @"推广来源";
            break;
        }
        case CallSourceType_visit:
        {
            callSoucreText = @"定时访问";
            break;
        }
        default:
        {
            callSoucreText = @"推广来源";
            break;
        }
    }
    
    return callSoucreText;
}

@end
